<template>
  <div>
    <!--tab start-->
    <el-tabs v-model="tabName">
      <el-tab-pane v-if="$isAuthBtn(['SP_TAB_SP_PKG'])" label="服务商权限组" name="spPackagePage">
        <SpPackagePage v-if="tabName==='spPackagePage'" :tab-name="tabName" @editPackage="editPackage" />
      </el-tab-pane>
      <el-tab-pane v-if="$isAuthBtn(['SP_TAB_MCH_PKG'])" label="商户权限组" name="mchPackagePage">
        <MchPackagePage v-if="tabName==='mchPackagePage'" :tab-name="tabName" @editPackage="editPackage" />
      </el-tab-pane>
      <el-tab-pane label="我的标签" name="tagList">
        <TagList v-if="tabName==='tagList'" :tab-name="tabName" />
      </el-tab-pane>
      <el-tab-pane v-if="$isAuthBtn(['SP_RADIO_BOX_SP_PKG','SP_RADIO_BOX_MCH_PKG'])" label="添加权限组" name="addPackageForm">
        <PackageForm v-if="tabName==='addPackageForm'" :tab-name="tabName" mode="add" />
      </el-tab-pane>
      <el-tab-pane v-if="tabName==='editPackageForm'&&packageId" label="编辑权限组" name="editPackageForm">
        <PackageForm :package-id="packageId" mode="edit" :tab-name="tabName" :package-type="packageType" />
      </el-tab-pane>
    </el-tabs>
    <!--tab end-->
  </div>
</template>

<script>
import MchPackagePage from './components/MchPackagePage'
import SpPackagePage from './components/SpPackagePage'
import TagList from './components/TagList'
import PackageForm from './components/PackageForm'

export default {
  components: {
    SpPackagePage,
    MchPackagePage,
    TagList,
    PackageForm
  },
  data() {
    return {
      // 配置
      // 状态
      // 数据
      tabName: 'spPackagePage',
      packageType: 'sp',
      packageId: null
    }
  },
  computed: {},
  watch: {},
  beforeCreate() {
  },
  created() {
  },
  beforeMount() {
  },
  mounted() {
    if (this.$isAuthBtn(['SP_TAB_SP_PKG'])) {
      this.tabName = 'spPackagePage'
    } else if (this.$isAuthBtn(['SP_TAB_MCH_PKG'])) {
      this.tabName = 'mchPackagePage'
    } else {
      this.tabName = 'tagList'
    }
  },
  beforeUpdate() {
  },
  update() {
  },
  activated() {
  },
  deactivated() {
  },
  beforeDestroy() {
  },
  destroyed() {
  },
  methods: {
    /**
     * 数据组
     */
    /**
     * 按钮组
     */
    /**
     * 状态组
     */
    // 编辑
    editPackage(res) {
      this.packageType = res.packageType
      this.packageId = res.packageId
      this.tabName = 'editPackageForm'
    }
    /**
     * 方法组
     */
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>

</style>
